<!--
 * @Author: 千锋爱佛僧
 * @公众号: 大前端私房菜
 * @Slogan: 千锋精品教程，好学得不像实力派！
-->
<template>
  <div class="box">
    <h1>这是B组件,{{ num }}</h1>
    <van-button type="primary" @click="num--">数字-</van-button>
    <van-button type="primary" @click="count.decrement(10)">传参-</van-button>
    <van-button type="primary" @click="handleMinus">通过$patch修改</van-button>
    <div v-for="item in parentList" :key="item.objectId">
      {{ item.name }}
    </div>
  </div>
</template>

<script setup lang="ts">
import { useCounter } from "../../store/count";
import { storeToRefs } from "pinia";
import { useClassify } from "../../store/classify";
const count = useCounter();
const { num } = storeToRefs(count);
const handleMinus = () => {
  count.$patch({
    num: 233,
  });
};

const { parentList } = storeToRefs(useClassify());
</script>

<style scoped>
.box {
  height: 50vh;
  border: 1px solid #333;
}
</style>
